import request from './http-interceptor';

export const HttpClient = {
  get: (url: string, params?: Object): any => {
    return request({
      url: url,
      method: 'get',
      params,
    });
  },

  post: (url: string, data?: Object): any => {
    return request({
      url: url,
      method: 'post',
      data,
    });
  },

  download: (url: string, params?: Object): any => {
    return request({
      url: url,
      method: 'get',
      params,
      responseType: 'blob',
    });
  },

  export: (url: string, data?: Object): any => {
    return request({
      url: url,
      method: 'post',
      data,
      responseType: 'blob',
    });
  },

  delete: (url: string, data?: Object): any => {
    return request({
      url: url,
      method: 'delete',
      data,
    });
  },

  put: (url: string, data?: Object): any => {
    return request({
      url: url,
      method: 'put',
      data,
    });
  },

  upload: (url: string, data?: Object): any => {
    return request({
      url: url,
      method: 'post',
      data,
      headers: { 'Content-Type': 'multipart/form-data' },
    });
  },
};
